home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Cafe 3
/
Visual Cafe 3.ISO
/
Vcafe
/
Main.bin
/
ExecutionContext.java
< prev
next >
Wrap
Text File
|
1998-10-07
|
5KB
|
201 lines
package com.symantec.itools.lang;
import java.io.IOException;
import java.util.StringTokenizer;
import com.symantec.itools.util.Properties;
import com.symantec.itools.util.KeyNotFoundException;
/**
* Symantec1.1WindownNT4.0x86ExecutionContextParser
* Symentec1.1Windowsx86ExecutionContextParser
* Symantec1.1x86ExecutionContextParser
* Symantec1.1ExecutionContextParser
* SymantecExecutionContextParser
*
* @author Symantec Internet Tools Division
* @version 1.0
* @since VCafe 3.0
*/
public class ExecutionContext
{
/**
* @since VCafe 3.0
*/
protected static Class parserClass;
/**
* @since VCafe 3.0
*/
protected ExecutionContextParser parser;
static
{
parserClass = lookupParser();
}
protected ExecutionContext()
{
}
public ExecutionContext(String stackTrace, int level)
{
try
{
parser = (ExecutionContextParser)parserClass.newInstance();
parser.parse(stackTrace, level);
}
catch(InstantiationException ex)
{
ex.printStackTrace();
}
catch(IllegalAccessException ex)
{
ex.printStackTrace();
}
}
/**
* @since VCafe 3.0
*/
private static Class lookupParser()
{
return (lookupParser(AccessiblePlatform.getJavaVendor(), AccessiblePlatform.getJavaVersion(),
AccessiblePlatform.getOSName(), AccessiblePlatform.getOSVersion(),
AccessiblePlatform.getOSType(), AccessiblePlatform.getArchitecture()));
}
private static Class lookupParser(String javaVendor, String javaVersion, String osName, String osVersion,
String osType, String architecture)
{
try
{
Properties properties;
Class clazz;
properties = new Properties("/com/symantec/itools/lang/ExecutionContext.properties");
if(javaVendor == null)
{
return (DefaultExecutionContextParser.class);
}
properties = properties.getProperties(javaVendor);
if(properties != null)
{
clazz = lookupParser(properties, javaVendor + javaVersion + osName + osVersion + architecture);
if(clazz == null)
{
clazz = lookupParser(properties, javaVendor + javaVersion + osType + architecture);
if(clazz == null)
{
clazz = lookupParser(properties, javaVendor + javaVersion + architecture);
if(clazz == null)
{
clazz = lookupParser(properties, javaVendor + javaVersion);
if(clazz == null)
{
clazz = lookupParser(properties, javaVendor);
}
}
}
}
if(clazz != null)
{
return (clazz);
}
}
}
catch(IOException ex)
{
ex.printStackTrace();
}
catch(Throwable ex)
{
ex.printStackTrace();
}
return (DefaultExecutionContextParser.class);
}
private static Class lookupParser(Properties properties, String key)
{
try
{
return (properties.getClass(key));
}
catch(ClassNotFoundException ex)
{
}
catch(KeyNotFoundException ex)
{
}
return (null);
}
/**
* @since VCafe 3.0
*/
public String getFile()
{
return (parser.getFile());
}
/**
* @since VCafe 3.0
*/
public String getClazz()
{
return (parser.getClazz());
}
/**
* @since VCafe 3.0
*/
public String getMethod()
{
return (parser.getMethod());
}
/**
* @since VCafe 3.0
*/
public int getLine()
{
return (parser.getLine());
}
/**
* @since VCafe 3.0
*/
public String toString()
{
int line;
String lineStr;
line = getLine();
lineStr = (line == -1) ? "unknown" : Integer.toString(line);
return (getFile() + " " + getClazz() + "." + getMethod() + "(" + lineStr + ")");
}
public static void main(String[] argv)
{
System.out.println(com.symantec.itools.lang.Debug.getExecutionContext(0));
}
}